package com.yenlien.traceyun.business.service.rest.usercenter;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.business.bean.RestURL;
import com.yenlien.traceyun.business.service.rest.RestService;
import com.yenlien.traceyun.webase.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by LiuSha on 2020/6/12.
 */
@Service
public class DepartmentRestService {
    @Autowired
    private RestService restService;

    public Object findByList(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "department/findByList", jsonObject);
    }

    public Object save(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "department/save", jsonObject);
    }

    public Object update(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "department/update", jsonObject);
    }

    public Object delete(String id) {
        return restService.getJson(RestURL.USERCENTER + "department/delete/" + id);

    }

    public Object findById(String id) {
        return restService.getJson(RestURL.USERCENTER + "department/findById/" + id);

    }

    public Object findByAll(String companyId) {
        return restService.getJson(RestURL.USERCENTER + "department/findByAll/" + companyId);
    }

    public Object chain(String companyId) {
        return restService.getJson(RestURL.USERCENTER + "department/company/chain/" + companyId);
    }

    /*****/

    /**
     * 绑定权限
     *
     * @param jsonObject
     * @return
     */
    public Object bindResources(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "department/bindresource", jsonObject);
    }

    /**
     * 加载权限
     *
     * @param id
     * @return
     */
    public Object loadResources(String id) {
        return restService.getJson(RestURL.USERCENTER + "department/loadresource/" + id);
    }
}
